package com.kerbores.meeting.domain;

import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Table;
import org.nutz.json.Json;

/**
 * @author Kerbores
 *
 *         Create At 2015年1月8日 下午2:17:13
 */
@Table("m_device")
public class Device extends Entity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 设备类型枚举
	 * 
	 * @author Kerbores
	 *
	 *         Create At 2015年1月8日 下午2:45:56
	 */
	public static enum DeviceType {
		UNKNOW(0, "Unknow"), ANDROID(1, "Andriod"), IPAD(2, "Ipad"), WP(3, "");
		public static DeviceType from(int value) {
			for (DeviceType type : values()) {
				if (type.getValue() == value) {
					return type;
				}
			}
			return UNKNOW;
		}
		private int value;

		private String name;

		/**
		 * @param value
		 * @param name
		 */
		private DeviceType(int value, String name) {
			this.value = value;
			this.name = name;
		}

		/**
		 * @return the name
		 */
		public String getName() {
			return name;
		}

		/**
		 * @return the value
		 */
		public int getValue() {
			return value;
		}

		/**
		 * @param name
		 *            the name to set
		 */
		public void setName(String name) {
			this.name = name;
		}

		/**
		 * @param value
		 *            the value to set
		 */
		public void setValue(int value) {
			this.value = value;
		}

	}

	/**
	 * 设备生成的uuid
	 */
	@Column("uid")
	private String uid;
	/**
	 * 设备类型
	 */
	@Column("device_type")
	private DeviceType deviceType;

	/**
	 * @return the deviceType
	 */
	public DeviceType getDeviceType() {
		return deviceType;
	}

	/**
	 * @return the uid
	 */
	public String getUid() {
		return uid;
	}

	/**
	 * @param deviceType
	 *            the deviceType to set
	 */
	public void setDeviceType(DeviceType deviceType) {
		this.deviceType = deviceType;
	}

	/**
	 * @param uid
	 *            the uid to set
	 */
	public void setUid(String uid) {
		this.uid = uid;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return Json.toJson(this);
	}

}
